
import numpy
import cv2
import os

image_width = 4
image_height = 3
color_chns = 3

# Make an array of 120,000 random bytes.
random_byte_array = bytearray(os.urandom(color_chns*image_height*image_width))
print( random_byte_array )
flat_numpy_array = numpy.array(random_byte_array)
print( flat_numpy_array )

# Convert the array to make a 400*300 grayscale image.
grayImage = flat_numpy_array.reshape( image_height, image_width, color_chns )
cv2.imwrite ( "RandomGray.png", grayImage )
# print( grayImage )

# Convert the array to make a 400 * 100 color image.
bgrImage = flat_numpy_array.reshape( image_height, image_width, color_chns)
cv2.imwrite ( "RandomColor.png", bgrImage )

